<?php
/**
*
 */
define('IN_DOUCO', true);

// 强制在移动端中显示PC版
if (isset($_REQUEST['mobile'])) {
   setcookie('client', 'pc');
   if ($_COOKIE['client'] != 'pc') $_COOKIE['client'] = 'pc';
}

require (dirname(__FILE__) . '/include/init.php');


if ($_REQUEST['lang']) {
    $lang = $_REQUEST['lang'];
}else{
    $lang = 'zh';
}
require (dirname(__FILE__) . '/common.php');

$smarty->assign('dangqun_url', get_dangqun($lang));
$smarty->assign('zhaosheng_url', get_zhaosheng($lang));

if ($_REQUEST['type']) {
    $type = $_REQUEST['type'];
}else{
    $type = '0';
}

if ($_REQUEST['cat_id']){
    $cat_id = $_REQUEST['cat_id'];
}else{
    $cat_id = '10';
}

if ($_REQUEST['date']){
    $where = ' WHERE cat_id IN (' . $cat_id . ') and lang=\''. $lang.'\' and date=\'' . $_REQUEST['date'].'\'';
}else{
    $where = ' WHERE cat_id IN (' . $cat_id . ') and lang=\''. $lang.'\'';
}


// 获取分页信息
$page = $check->is_number($_REQUEST['page']) ? trim($_REQUEST['page']) : 1;
list($limit,$article_num,$sqlexp) = $dou->pager2('article', ($_DISPLAY['article'] ? $_DISPLAY['article'] : 10), $page, $dou->rewrite_url('article_category', $cat_id), $where);

/* 获取文章列表 */
$sql = "SELECT id, title, content, image, cat_id, add_time, author, publisher, date ,description, file1 FROM " . $dou->table('article') . $where . " ORDER BY date DESC, title" . $limit;
$query = $dou->query($sql);

while ($row = $dou->fetch_array($query)) {
    $url = 'info.php?id='.$row['id'];

    $add_time = date("Y-m-d", $row['add_time']);
    $add_time_short = date("m-d", $row['add_time']);
    $image = $row['image'] ? ROOT_URL . $row['image'] : '';
    
    // 如果描述不存在则自动从详细介绍中截取
    $description = $row['description'] ? $row['description'] : $dou->dou_substr($row['content'], 200, false);

    $article_list[] = array (
            "id" => $row['id'],
            "cat_id" => $row['cat_id'],
            "title" => $row['title'],
            "image" => $image,
            "add_time" => $add_time,
            "author" => $row['author'],
            "publisher" => $row['publisher'],
            "description" => $description,
            "file1" => $row['file1'],
            "year" => $row['date'],
            "url" => $url 
    );
}


$smarty->assign('article_list', $article_list);
$smarty->assign('article_num', $article_num);
$smarty->assign('lang', $lang);


// 赋值给模板-数据
$smarty->display('list_scientific_publications.dwt');

?>
